#pragma once
#include "../common/lua_version.h"
#include "lua_utils.h"
#include "Win32Utils/fcjson.h"

class lua_json
{

public:
    static void initialize(lua_State* L, const char* lib_name);
    static void uninitialize();

    static int decode(lua_State* L);
    static int encode(lua_State* L);

private:

    static void _decode_object(lua_State* L, const fcjson::json_value& val);
    static void _decode_array(lua_State* L, const fcjson::json_value& val);
    static void _decode_value(lua_State* L, const fcjson::json_value& val);

    static void _encode_object(lua_State* L, std::string& strJson);
    static void _encode_value(lua_State* L, int index, std::string& strJson);
};

